package xy.common.exception.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import xy.common.exception.global.MyException;

@RestController
public class HaloController {

    /**
     * 测试自定义异常
     * @return
     * @throws MyException
     */
    @GetMapping("test")
    public String testLogin() throws MyException {
        throw new MyException("测试自定义异常");
    }

    /**
     * 测试算术异常
     * @return
     * @throws MyException
     */
    @GetMapping("mathException")
    public String testMathException() throws MyException{
        System.out.println(1/0);
        return "123";
    }

    /**
     * 测试空指针异常
     * @return
     * @throws MyException
     */
    @GetMapping("testNullException")
    public String testNullException() throws MyException{
        String str = null;
        System.out.println(str.length());
        return "123";
    }
}
